
/*
*			高级抽象线程类头文件
*/

#pragma once

#include <boost/thread.hpp>
#include <boost/noncopyable.hpp>
#include <boost/ref.hpp>

#include "CxType.h"
namespace ImitateTansfer
{

	using	boost::noncopyable;
	using	boost::thread;
	using	boost::ref;


	//线程接口类


	struct CxThread	: public  noncopyable		
	{
		virtual			~CxThread(){}

		virtual bool	Begin()=0;						//开始线程
		virtual bool	Close()=0;						//关闭线程

		virtual bool	Suspend()=0;					//暂停线程
		virtual bool	Continue()=0;					//继续线程

		virtual UINT	GetStatus()const=0;
	};



	class  ImpCxThread	:	public CxThread
	{
	public:

		ImpCxThread():m_status(THREAD_RUNNING)
		{
			m_thread=thread(__ThreadFunc,ref(*this));
		}
		virtual			~ImpCxThread(){}

		virtual UINT	GetStatus()const{return m_status;}

	protected:

		virtual	void	ThreadFunc()=0;

	protected:

        static	void   __ThreadFunc(ImpCxThread &obj)
		{
			obj.ThreadFunc();
		}	

		thread	m_thread;
		UINT	m_status;
	};

}
